package cn.wolfcode.wolf2w.business.service.impl;

import cn.wolfcode.wolf2w.api.RemoteQuestionService;
import cn.wolfcode.wolf2w.api.domain.Question;
import cn.wolfcode.wolf2w.api.domain.QuestionSearch;
import cn.wolfcode.wolf2w.business.repository.QuestionRepository;
import cn.wolfcode.wolf2w.business.service.IQuestionSearchService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 浪兎兎
 * @since 2025-06-12 15:19
 */
@Service
public class QuestionSearchServiceImpl implements IQuestionSearchService {
    @Autowired
    private RemoteQuestionService questionService;
    @Autowired
    private QuestionRepository questionRepository;
    @Override
    public void initSearch() {
        List<Question> result = questionService.list("inner").getData();
        result.forEach(question -> {
            QuestionSearch questionSearch = new QuestionSearch();
            BeanUtils.copyProperties(question, questionSearch);
            questionRepository.save(questionSearch);
        });
    }
}
